#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80

ENV TZ=Asia/Shanghai \
    DEBIAN_FRONTEND=noninteractive

RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime \
    && echo ${TZ} > /etc/timezone \
    && dpkg-reconfigure --frontend noninteractive tzdata \
    && rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Src/edan.zhjk.MCPWebApi/edan.zhjk.MCPWebApi.csproj", "Src/edan.zhjk.MCPWebApi/"]
COPY ["Src/edan.zhjk.Commons/edan.zhjk.Commons.csproj", "Src/edan.zhjk.Commons/"]
RUN dotnet restore "./Src/edan.zhjk.MCPWebApi/./edan.zhjk.MCPWebApi.csproj"
COPY . .
WORKDIR "/src/Src/edan.zhjk.MCPWebApi"
RUN dotnet build "./edan.zhjk.MCPWebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./edan.zhjk.MCPWebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "edan.zhjk.MCPWebApi.dll"]